package com.olympus.hermes.product.constants;

import com.olympus.hermes.common.constants.BaseEnum;
import com.olympus.hermes.common.constants.EnumConverter;

import java.util.Optional;

/**
 * 商品上架状态
 * @author Mickey
 * @since 2021/2/5
 */
public enum PublishState implements BaseEnum<PublishState> {

    NEW(0, "新建"),
    ON_SALE(1, "上架"),
    OFF_SALE(2,"下架")
    ;

    private final Integer code;
    private final String msg;

    PublishState(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    @Override
    public Integer getCode() {
        return this.code;
    }

    @Override
    public String getName() {
        return this.msg;
    }

    public static Optional<PublishState> of(Integer code) {
        return Optional.ofNullable(BaseEnum.parseByCode(PublishState.class, code));
    }

    public static class Converter extends EnumConverter<PublishState> {

    }
}
